package com.thoughtworks.preuniversity.biblioteca;

import java.io.IOException;
import java.util.Scanner;

/**
 * Created by padmavb on 6/12/14.
 */
public class UserInterface {


    public void displayWelcome(String stringToDisplay){

        System.out.print(stringToDisplay);
    }
    public void displayMessage(String stringToDisplay) {

        System.out.print(stringToDisplay+"\n");
    }

    public String readBookTitle() {

        Scanner scanner=new Scanner(System.in);
        String inputFromUser=scanner.nextLine();
        inputFromUser=inputFromUser.trim();

        return inputFromUser;
    }



    public void displayBookDetails(Book bookObjectToDisplay) {

       System.out.format("%-30s%-30s%-30s\n" ,bookObjectToDisplay.getTitle(),bookObjectToDisplay.getAuthorName(),
               bookObjectToDisplay.getPublishedYear() );
    }

    public void displayBookFormat() {

        System.out.format("%-30s%-30s%-30s\n","Book title","Author Name","Published year");
        System.out.format("=======================================================================\n");

    }

    public int readUserChoice() throws IOException{

        Scanner scanner=new Scanner(System.in);
        int userChoice=Integer.parseInt(scanner.nextLine());
        return userChoice;

    }


    public void displayMenuItems(String listOfAvailableMenuOptions) {

        System.out.print(listOfAvailableMenuOptions);
    }

    public void displayMovieDetails(Movie movieObjectToDisplay) {


        System.out.format("%-30s%-30s%-30s%-30s\n" ,movieObjectToDisplay.getName(),movieObjectToDisplay.getYear(),
                movieObjectToDisplay.getDirector(),movieObjectToDisplay.getRating() );
    }

    public void displayMovieFormat() {

        System.out.format("%-30s%-30s%-30s%-30s\n","Movie Name","Year","Director","Rating");
        System.out.format("=======================================================================\n");
    }

    public String readMovieTitle() {

        Scanner scanner=new Scanner(System.in);
        String movieToCheckOut=scanner.nextLine();
        movieToCheckOut=movieToCheckOut.trim();

        return  movieToCheckOut;
    }

    public String readLibraryNumber() {

        Scanner scanner=new Scanner(System.in);
        String libraryNumber=scanner.nextLine();
        libraryNumber=libraryNumber.trim();

        return libraryNumber;
    }

    public String readPassword() {

        Scanner scanner=new Scanner(System.in);
        String password=scanner.nextLine();
        password=password.trim();

        return password;
    }

    public void displayUserInfo(User loginUserInfo) {

        System.out.format("%-30s%-30s%-30s\n","Name","Email id","Phone number");
        System.out.format("=======================================================================\n");
        System.out.format("%-30s%-30s%-30s\n" ,loginUserInfo.getName(),loginUserInfo.getEmailId(),
                loginUserInfo.getPhoneNumber() );

    }
}
